package com.jp.knowledge.fragment;

import com.jp.knowledge.adapter.SearchTeamCircleAdapter;
import com.jp.knowledge.comm.JpApplication;
import com.jp.knowledge.model.IModel;
import com.jp.knowledge.model.TeamCircleModel;
import com.jp.knowledge.view.JpDiver;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 528787067@qq.com on 2017/2/17.
 */

public class SearchTeamCircleFragment extends SearchDetailFragment {

    private List<TeamCircleModel> teamCircleModels;
    private SearchTeamCircleAdapter teamCircleAdapter;

    @Override
    protected void initData() {
        super.initData();

        teamCircleModels = new ArrayList<>();
        teamCircleAdapter = new SearchTeamCircleAdapter(mContext, teamCircleModels);
        recyclerView.setAdapter(teamCircleAdapter);
        recyclerView.addItemDecoration(new JpDiver(mContext));
    }

    @Override
    public void done(IModel dataModel) {
        super.done(dataModel);
        List<TeamCircleModel> datas = dataModel.getList(TeamCircleModel.class);
        if(teamCircleModels == null)
            teamCircleModels = new ArrayList<>();
        if(isFresh) {
            teamCircleModels.clear();
            footerView.setLoadComplete(false);
        } else if(datas == null || datas.size() == 0){
            footerView.setLoadComplete(true);
        }
        teamCircleModels.addAll(datas);
        teamCircleAdapter.updateAdapter(teamCircleModels);
    }
}
